package cn.hftoday.org;

import java.util.*;
import org.apache.log4j.*;
import cn.hftoday.db.*;
import cn.hftoday.core.*;
import cn.hftoday.util.*;

/**
 * company
 * @author lane.cn@gmail.com
 *
 */
public class Company extends PartyBase {
	private static final Logger LOG = Logger.getLogger(Company.class);
	
	public static final String ICON = "company_icon.png";
	
	private String alias;
	private String city;
	private String address;
	private String taxNo;
	private Calendar foundTime = CalendarParser.INVALID_TIME;
	private String scale;
	private String industry;
	
	public String getAlias() {
		return alias;
	}
	
	public void setAlias(String alias) {
		this.alias = alias;
	}
	
	public String getCity() {
		return city;
	}
	
	public void setCity(String city) {
		this.city = city;
	}
	
	public String getAddress() {
		return address;
	}
	
	public void setAddress(String address) {
		this.address = address;
	}
	
	public String getTaxNo() {
		return taxNo;
	}
	
	public void setTaxNo(String taxNo) {
		this.taxNo = taxNo;
	}
	
	public Calendar getFoundTime() {
		return foundTime;
	}
	
	public void setFoundTime(Calendar foundTime) {
		this.foundTime = foundTime;
	}
	
	public String getScale() {
		return scale;
	}
	
	public void setScale(String scale) {
		this.scale = scale;
	}
	
	public String getIndustry() {
		return industry;
	}
	
	public void setIndustry(String industry) {
		this.industry = industry;
	}
	
	public String getPartyType() {
		return "company";
	}

	private static void _select(Object object, RecordSet rs, int i) {
		Company o = (Company)object;
		o.id = rs.getItem(i, "f_id");
		o.name = rs.getItem(i, "f_name");
		o.hidden = rs.getItem(i, "f_hidden").equals("1");
		o.createTime = CalendarParser.toCalendar(rs.getItem(i, "f_createtime"));
		o.updateTime = CalendarParser.toCalendar(rs.getItem(i, "f_updatetime"));
		o.alias = rs.getItem(i, "f_alias");
		o.city = rs.getItem(i, "f_city");
		o.address = rs.getItem(i, "f_address");
		o.taxNo = rs.getItem(i, "f_taxno");
		o.foundTime = CalendarParser.toCalendar(rs.getItem(i, "f_founddate"));
		o.scale = rs.getItem(i, "f_scale");
		o.industry = rs.getItem(i, "f_industry");
	}
	
	private static String _insert(Object object, String sql) {
		Company o = (Company)object;
		return StringParser.formatSql(sql, 
			o.id,
			o.name,
			o.hidden ? "1" : "0",
			CalendarParser.toString(o.createTime),
			CalendarParser.toString(o.updateTime),
			o.alias,
			o.city,
			o.address,
			o.taxNo,
			CalendarParser.toString(o.foundTime),
			o.scale,
			o.industry
		);
	}
	
	private static String _update(Object object, String sql) {
		Company o = (Company)object;
		return StringParser.formatSql(sql, 
			o.id,
			o.name,
			o.hidden ? "1" : "0",
			CalendarParser.toString(o.createTime),
			CalendarParser.toString(o.updateTime),
			o.alias,
			o.city,
			o.address,
			o.taxNo,
			CalendarParser.toString(o.foundTime),
			o.scale,
			o.industry
		);
	}
	
	private static String _delete(Object object, String sql) {
		Company o = (Company)object;
		return StringParser.formatSql(sql, o.id);
	}
}

